﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DataAccess;

namespace ServiceController
{
    public partial class ServiceController
    {
        public event ServiceControllerEventHandler GetListHostServiceCompleted;
        public event ServiceControllerEventHandler GetHostServicePropertyCompleted;
        public event ServiceControllerEventHandler GetDeploymentPropertyComplete;
        public event ServiceControllerEventHandler ChangeConfigFileComplete;
        public event ServiceControllerEventHandler UpdateDeploymentStatusComplete;
        public event ServiceControllerEventHandler DeleteDeploymentComplete;
        public event ServiceControllerEventHandler UpgradeDeploymentComplete; 
        public event ServiceControllerEventHandler SwapComplete;
        public event ServiceControllerEventHandler CreateComplete;
        public event ServiceControllerEventHandler GetOperationStatusComplete;
        DataAccess.DataAccess da;

        public ServiceController()
        {
            da = new DataAccess.DataAccess();
            _ListHostServiceDelegate = new ListHostServiceDelegate(GetListHostServices);
            _GetHostServicePropertyDelegate = new GetHostServicePropertyDelegate(GetHostServiceProperty);
            _GetDeploymentPropertyDelegate = new GetDeploymentPropertyDelegate(GetDeploymentProperty);
            _ChangeConfigurationFileDelegate = new ChangeConfigurationFileDelegate(ChangeConfigurationFile);
            _CreateDeployDelegate = new CreateDeployDelegate(CreateDeploy);
            _DeleteDeploymentDelegate = new DeleteDeploymentDelegate(DeleteDeployment);
            _SwapDelegate = new SwapDelegate(Swap);
            _UpdateDeploymentStatusDelegate = new UpdateDeploymentStatusDelegate(UpdateDeploymentStatus);
            _UpgradeDeploymentDelegate = new UpgradeDeploymentDelegate(UpgradeDeployment);
            _GetOperationStatusDelegate = new GetOperationStatusDelegate(GetOperationStatus);
        }

        public void OnGetOperationStatusComplete(ServiceControllerEventArgs e)
        {
            if (GetOperationStatusComplete != null)
            {
                GetOperationStatusComplete(this, e);
            }

        }

        public void OnGetListHostServiceCompleted(ServiceControllerEventArgs e)
        {
            if (GetListHostServiceCompleted != null)
            {
                GetListHostServiceCompleted(this, e); 
            }
             
        }
        public void OnGetHostServicePropertyCompleted(ServiceControllerEventArgs e)
        {
            if (GetHostServicePropertyCompleted != null)
            {
                GetHostServicePropertyCompleted(this, e);
            }
          
        }
        
        public void OnGetDeploymentPropertyComplete(ServiceControllerEventArgs e)
        {
            if (GetDeploymentPropertyComplete != null)
            {
                GetDeploymentPropertyComplete(this, e);
                 
            }
        }
        public void OnChangeConfigFileComplete(ServiceControllerEventArgs e)
        {
            if (ChangeConfigFileComplete != null)
            {
                ChangeConfigFileComplete(this, e);
            }
        
        
        }
        public void OnUpdateDeploymentStatusComplete(ServiceControllerEventArgs e)
        {
            if (UpdateDeploymentStatusComplete != null)
            {
                UpdateDeploymentStatusComplete(this, e);
            }
        }
        public void OnDeleteDeploymentComplete(ServiceControllerEventArgs e)
        {
            if (DeleteDeploymentComplete != null)
            {
                DeleteDeploymentComplete(this, e);
            }
        }
        public void OnUpgradeDeploymentComplete(ServiceControllerEventArgs e)
        {
            if (UpgradeDeploymentComplete != null)
            {
                UpgradeDeploymentComplete(this, e);
            }
        }
        public void OnSwapComplete(ServiceControllerEventArgs e)
        {
            if (SwapComplete != null)
            {
                SwapComplete(this, e);
            }
        }
        public void OnCreateComplete(ServiceControllerEventArgs e)
        {
            if (CreateComplete!=null)
             {
                 CreateComplete(this, e);
             }
        }
        

    }
}
